package com.lpf.ext;

import java.util.Arrays;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    /**
     * 功能描述：bean 定义已经被加载，但还未创建对象的时候工作
     *
     * @author  lpf
     * @since   2019-05-29 20:13:13
     * @param   beanFactory
     * @return  void
     */
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

        System.out.println("*******MyBeanFactoryPostProcessor...postProcessBeanFactory...");

        int count = beanFactory.getBeanDefinitionCount();
        String[] names = beanFactory.getBeanDefinitionNames();

        System.out.println("当前BeanFactory中有 " + count + " 个Bean");
        System.out.println(Arrays.asList(names));
    }

}
